package com.suixun.controller.credits;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.authority.controller.BaseManager;
import com.suixun.entity.credits.CreditTaskArchive;
import com.suixun.service.credits.CreditTaskArchiveService;
import com.suixun.util.Constant;

/**
 * 积分档案
 * 
 * @author yh
 * @date 2017年11月15日
 */
@RestController
@RequestMapping(value = "/credits/task/archive")
public class CreditTaskArchiveController extends BaseManager {

    // 积分档案
    @Autowired
    private CreditTaskArchiveService taskArchiveService;

    @RequestMapping(value = "add_update.json", method=RequestMethod.POST)
    public Object addOrUpdate(@RequestParam(value = "id", required = false)Integer id) {
        try {
            CreditTaskArchive cta = new CreditTaskArchive();
            cta.setAuthUserId(getUserId().intValue());
            if(id != null){
                cta.setId(id);
            }
            taskArchiveService.addOrUpdate(cta);
            return success();
        } catch (Exception e) {
            logger("CreditTaskArchiveController insert:" + e.getMessage(), e);
            return fail(Constant.EXCEPTION.OPERATE_FAIL);
        }
    }

}
